<template>
    <div class="quarterly_report">
        <div v-if="xianshi == '0' || xianshi == '4'"> 
            
            <xlUntil text="引进企业情况" :queryParam="queryParam" v-show="test" :untilVisible="true" :importBtn="false" :filtersVislble="true" :exportXlsData="exportXlsData"  :addBtn="status != 1"  v-bind="$attrs" @delBatch="delBatch" @addForm="addForm"  @searchKeyWord="searchKeyWord"  :export-xls-url="url.exportXlsUrl"></xlUntil>
        </div>
        <div class="xl-table-content">
            <xlTable
                    :columns="columns"
                    :dataSource="data"
                    rowKey="id"
                    :pagination="pagination"
                    :loading="loading"
                    @change="handleTableChange"
                    bordered
                    :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
                >
                <template v-slot:action="scope">
                    <div v-if="status == 1 || status == 3">
                       <a @click="seeForm(scope.record)">查看</a>
                   </div>
                   <div v-else>
                        <a @click="editForm(scope.record)" v-if="test">编辑</a>
                        <a @click="seeForm(scope.record)" v-else>查看</a>
                        <a-divider type="vertical"/>
                        <a-dropdown v-if="test">
                            <a class="ant-dropdown-link" >更多 <a-icon type="down"/></a>
                            <a-menu slot="overlay" >
                                <a-menu-item @click="quarterForm(scope.record)">
                                    <a>季度填报</a>
                                </a-menu-item>
                                <a-menu-item @click="seeForm(scope.record)">
                                    <a>查看</a>
                                </a-menu-item>
                                <a-menu-item @click="moveOutForm(scope.record)">
                                    <a>迁出</a>
                                </a-menu-item>
                                <a-menu-item>
                                    <a-popconfirm title="确定删除吗?" @confirm="() => delForm(scope.record.id)">
                                        <a>删除</a>
                                    </a-popconfirm>
                                </a-menu-item>
                            </a-menu>
                        </a-dropdown>
                   </div>
                </template>
            </xlTable>
        </div>
        <xlForm ref="xlForm" @handleOk="handleOk"></xlForm>
        <monForm :column="2" ref="monForm" @handleOk="handleOk"></monForm>
        <seeForm ref="seeForm"></seeForm>
    </div>
</template>

<script>
    import {companyMoveOut} from '@/assets/api/new'

    import xlMixin from '../../mixin/index'
    import seeForm from '../../../views/new/hatch_company/model/see'
    import monForm from '../../../views/new/hatch_company/model/form'
    
    export default {
        name: "index",
        mixins:[xlMixin],
        data(){
            return{
                columns:[
                    {
                        title: '编号',
                        key: 'rowIndex',
                        align: "center",
                        fixed: 'left',
                        width:'80px',
                        customRender: function (t, r, index) {
                            return parseInt(index) + 1;
                        }
                    },
                    {
                        title: '企业名称',
                        dataIndex: 'companyName',
                        fixed: 'left',
                        type:'assignSelect',
                        typeData:{
                            url:'/ndo/api/ndo/hatch/company/introduction/page/_list',
                            selectValue:'id',
                            selectName:'companyName',
                            addBtn:true,
                            editType:1
                        }
                    },
                    {
                        title: '统一社会信用代码',
                        dataIndex: 'creditCode',
                        // tableVisible:true, 列表不展示
                        type:'input'
                    },
                    {
                        title: '行业代码',
                        dataIndex: 'industryCode',
                        type:'input'
                    },
                    {
                        title: '引进时间',
                        dataIndex: 'createDateTime',
                        type:'input',
                        tableVisible: true,
                        formVisible: true
                    },
                    {
                        title: '注册时间',
                        dataIndex: 'registerDate',
                        type:'date'
                    },
                    {
                        title: '成立时间',
                        dataIndex: 'establishDate',
                        type:'date'
                    },
                    {
                        title: '注册地址',
                        dataIndex: 'registerAddress',
                        type:'input'
                    },
                   
                    {
                        title: '产业领域',
                        dataIndex: 'industrialDomain',
                        type:'select',
                        typeData:'NDO_FIELD'
                    },
                    {
                        title: '孵化方式',
                        dataIndex: 'hatchingMode',
                        type:'input'
                    },
                    {
                        title: '注册资本(万元)',
                        dataIndex: 'registeredCapital',
                        type:'input.number'
                    },
                    // {
                    //     title: '本季度营业收入(万元)',
                    //     dataIndex: 'businessIncome',
                    //     type:'input.number'
                    // },
                    {
                        title: '是否高企',
                        dataIndex: 'ht',
                        type:'radio',
                        typeData:[
                            {
                                dataName:'是',
                                dataValue: true
                            },
                            {
                                dataName:'否',
                                dataValue: false
                            }
                        ],
                        conditionF:{
                            clearKey:'htIdentifyYear',
                            clearValue:false
                        }
                    },
                    {
                        title: '高企认定年份',
                        dataIndex: 'htIdentifyYear',
                        required:false,
                        type: 'date',
                        typeData: 'year',
                        condition:{
                            conditionKey:'ht',
                            conditionValue:true
                        }
                    },
                    {
                        title: '是否市入库',
                        dataIndex: 'cityWarehousing',
                        type:'radio',
                        typeData:[
                            {
                                dataName:'是',
                                dataValue: true
                            },
                            {
                                dataName:'否',
                                dataValue: false
                            }
                        ],
                        defaultValue:false
                    },
                    {
                        title: '是否省入库',
                        dataIndex: 'provinceWarehousing',
                        type:'radio',
                        typeData:[
                           {
                                dataName:'是',
                                dataValue: true
                            },
                            {
                                dataName:'否',
                                dataValue: false
                            }
                        ],
                        defaultValue:false
                    },
                    {
                        title: '是否迁出',
                        dataIndex: 'moveOut',
                        type:'radio',
                        formVisible:true,
                        typeData:[
                           {
                                dataName:'是',
                                dataValue: true
                            },
                            {
                                dataName:'否',
                                dataValue: false
                            }
                        ]
                    },
                    {
                        title: '迁出时间',
                        required:false,
                        formVisible:true,
                        dataIndex: 'moveOutDate',
                        type:'date'
                    },
                    {
                        title: '机构人才持有股份',
                        required:false,
                        dataIndex: 'stock',
                        type:'input.number'
                    },
                    {
                        title: '机构股权投资增值(万元)',
                        required:false,
                        dataIndex: 'tzzz',
                        type:'input.number'
                    },
                    {
                        title: '机构持有股份占比(%)',
                        required:false,
                        dataIndex: 'ratio',
                        type:'input.number'
                    },
                    {
                        title: '机构出资方式',
                        dataIndex: 'methodCapital',
                        required:false,
                        type:'select',
                        typeData:'NDO_PUT'
                    },
                    {
                        title: '机构人才出资方式',
                        dataIndex: 'methodPerCapital',
                        required:false,
                        type:'select',
                        typeData:'NDO_PUT'
                    },
                    {
                        title: '已获社会融资金额(万元)',
                        dataIndex: 'financingAmount',
                        required:false,
                        type:'input.number'
                    },
                    {
                        title: '主营业务',
                        dataIndex: 'mainBusiness',
                        type:'textarea',
                        span:2
                    },
                    {
                        title: '营业执照', 
                        dataIndex: 'businessLicenseImageUrl',
                        type:'upload',
                        required:false,
                    },
                    
                    {
                        title: '操作',
                        dataIndex: 'action',
                        align: "center",
                        fixed: 'right',
                        width:'150px',
                        scopedSlots: {customRender: 'action'},
                    }
                ],
                exportXlsData:[
                    {
                        title:'企业名称',
                        dataIndex:'TNHC.COMPANY_NAME'
                    },
                    {
                        title:'企业类型',
                        dataIndex:'TNHC.COMPANY_TYPE'
                    },
                    {
                        title:'注册时间',
                        dataIndex:'TNHC.REGISTER_DATE'
                    },
                    {
                        title:'注册地址',
                        dataIndex:'TNHC.REGISTER_ADDRESS'
                    },
                    {
                        title:'成立时间',
                        dataIndex:'TNHC.ESTABLISH_DATE'
                    },
                    {
                        title:'行业代码',
                        dataIndex:'TNHC.INDUSTRY_CODE'
                    },
                    {
                        title:'注册资本',
                        dataIndex:'TNHC.REGISTERED_CAPITAL'
                    },
                    {
                        title:'统一社会信用代码',
                        dataIndex:'TNHC.CREDIT_CODE'
                    },
                    {
                        title:'主营业务',
                        dataIndex:'TNHC.MAIN_BUSINESS'
                    },
                    {
                        title:'是否高企',
                        dataIndex:'TNHC.HT'
                    },
                    {
                        title:'高企认定年份',
                        dataIndex:'TNHC.HT_IDENTIFY_YEAR'
                    },
                    {
                        title:'是否市入库',
                        dataIndex:'TNHC.CITY_WAREHOUSING'
                    },
                    {
                        title:'是否省入库',
                        dataIndex:'TNHC.PROVINCE_WAREHOUSING'
                    },
                    {
                        title:'产业领域',
                        dataIndex:'TNHC.INDUSTRIAL_DOMAIN'
                    },
                    {
                        title:'孵化方式',
                        dataIndex:'TNHC.HATCHING_MODE'
                    },
                    {
                        title:'企业营业执照附件',
                        dataIndex:'TNHC.BUSINESS_LICENSE_IMAGE_URL'
                    },
                    {
                        title:'新型研发机构名称',
                        dataIndex:'TNBI.NEW_DEV_ORG_NAME'
                    },
                    {
                        title:'机构人才持有股份',
                        dataIndex:'TNHC.STOCK'
                    },
                    {
                        title:'机构股权投资增值',
                        dataIndex:'TNHC.TZZZ'
                    },
                    {
                        title:'机构持有股份占比',
                        dataIndex:'TNHC.RATIO'
                    },
                    {
                        title:'机构出资方式',
                        dataIndex:'TNHC.METHOD_CAPITAL'
                    },
                    {
                        title:'机构人才出资方式',
                        dataIndex:'TNHC.METHOD_PER_CAPITAL'
                    },
                    {
                        title:'已获社会融资金额',
                        dataIndex:'TNHC.FINANCING_AMOUNT'
                    },
                ],
                // 请求参数
                paramMore:{
                    "newDevOrgId": ''
                },
                url: {
                    list: "/ndo/api/ndo/hatch/company/introduction/page/list",
                    add: '/ndo/api/ndo/hatch/company/introduction/save',
                    edit: '/ndo/api/ndo/hatch/company/introduction/save',
                    delete: "/ndo/api/ndo/hatch/company/remove",
                    deleteBatch: "/ndo/api/ndo/hatch/company/move/out",
                    exportXlsUrl: "ndo/api/new/dev/org/export/introduction/company",
                    importExcelUrl: "ndo/api/ndo/hatch/company/importExcel",
                    importExcelDemoUrl:'/ndo/api/ndo/hatch/company/importTemplate'
                }
            }
        },
        props:{
            newDevOrgId:Number,
            test:Boolean,  // 控制编辑是否显示
            status,
            xianshi:String, // 控制xlUntil是否显示
            code:String,   // 填报code
            reportId:Number, //填报id
        },
        created(){
            this.paramMore.newDevOrgId = this.newDevOrgId
            // this.paramMore.quarterlyReportCode = this.code
            this.formatMerge()
            this.pageOnload()
        },
        watch:{
           newDevOrgId(){
               this.paramMore.newDevOrgId = this.newDevOrgId
            //    this.paramMore.quarterlyReportCode = this.code
               this.pageOnload()
           }
       },
       methods:{
           // 迁出 
           moveOutForm(data){
               companyMoveOut({
                   param: data.id
                   }).then(result => {
                   console.log(result)
                   this.pageOnload()
               })
           },
            monForm(data){
                this.$refs.monForm.tableTitle = '月度经营数据'
                this.$refs.monForm.formatData(data,1)
                this.$refs.monForm.visible = true
                this.$refs.monForm.confirmLoading = false
                this.$refs.monForm.formatForm({})
                // this.$refs.monForm.type = true
            },
            quarterForm(data){
                this.$refs.monForm.tableTitle = '季度经营数据'
                this.$refs.monForm.formatData(data,2,this.code,this.reportId)
                this.$refs.monForm.visible = true
                this.$refs.monForm.confirmLoading = false
                this.$refs.monForm.formatForm({})
                // this.$refs.monForm.type = false
            },
            seeForm(data){
                this.$refs.seeForm.formatForm(data)
                this.$refs.seeForm.visible = true
            },
           addForm() {
            this.$refs.xlForm.tableTitle = '新增'
            this.$refs.xlForm.formatData(this.columns)
            this.$refs.xlForm.visible = true
            this.$refs.xlForm.confirmLoading = false
            this.$refs.xlForm.formatForm({ht:false,provinceWarehousing:false,cityWarehousing:false})
            this.$refs.xlForm.type = 1
        }
       },
       components:{
           seeForm,
           monForm
       }
    }
</script>
<style scoped>

</style>
